﻿using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jaqen.Lifenear.Contracts;
using Jaqen.Lifenear.Entity;

namespace Jaqen.Lifenear.Services
{
    public class UserService:DataService<LifenearContext>,IUserService
    {
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.All);
        }

        public int UserLogin(int userId)
        {
            return 1;
        }

        public int UserLogin(string userName, string userPwd)
        {
            return 1;
        }

        public int UserRegiste(string userName, string userPwd)
        {
            User user = new User();
            user.UserName = userName;
            user.UserPwd = userPwd;
            user.IsActive = false;

            var context = new LifenearContext();
            context.Users.Add(user);
            return context.SaveChanges();
        }
    }
}
